import time
from selenium import webdriver

import requests
from lxml import etree
from selenium.webdriver.common.by import By

bro = webdriver.Edge()
url = 'http://www.cqxs.gov.cn/'
bro.get(url)

# 标签定位
search_element = bro.find_element(By.ID, 'textfield')
# 标签交互
search_element.send_keys("梅江镇")

# 按照Xpath定位
btn = bro.find_element(By.XPATH, "/html/body/div[1]/div[3]/div/button")

# 模拟点击
btn.click()

# 执行一段js代码
bro.execute_script('window.scrollTo(0,document.body.scrollHeight)')
time.sleep(2)

bro.get("https://www.baidu.com")
time.sleep(2)
# 回退
bro.back()
time.sleep(2)

# 前进
bro.forward()

time.sleep(3)
bro.quit()
